package cn.iocoder.yudao.module.service.impl;

import cn.iocoder.yudao.module.VO.ScoreVo;
import cn.iocoder.yudao.module.mapper.ScoreMapper;
import cn.iocoder.yudao.module.pojo.Score;
import cn.iocoder.yudao.module.service.ScoreService;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ScoreServiceImpl implements ScoreService {
    @Autowired
    private ScoreMapper scoreMapper;

    @Override
    public void saveScore(ScoreVo score) {
        Score score1 = new Score();
//        BeanUtils.copyProperties(score1, score);
        score1.setScore(score.getScore());
        score1.setId(score.getId());
        score1.setSubject(score.getSubject());
        score1.setStudentId(score.getStudentId());
        scoreMapper.insertScore(score1);

    }

    @Override
    public void updateScore(ScoreVo score) {
        Score score1 = new Score();
//        BeanUtils.copyProperties(score1, score);
        score1.setScore(score.getScore());
        score1.setId(score.getId());
        score1.setSubject(score.getSubject());
        score1.setStudentId(score.getStudentId());
        scoreMapper.updateScore(score1);
    }

    @Override
    public void deleteScore(ScoreVo score) {
        Score score1 = new Score();
       // BeanUtils.copyProperties(score1, score);
        score1.setScore(score.getScore());
        score1.setId(score.getId());
        score1.setSubject(score.getSubject());
        score1.setStudentId(score.getStudentId());
        scoreMapper.deleteScore(score1);
    }

    @Override
    public Score getScoreById(Long id) {
        Score scoreById = scoreMapper.getScoreById(id);
        return scoreById;
    }
}
